<template>
  <div>
    <!-- 头部区域 -->
    <div class="header">
      <!-- 头部左侧Logo和标题 -->
      <a href="#/">
        <img class="logo" src="@/assets/img/logo.png" width="25px" height="25px" />
        <span class="company">文具1号商城管理系统</span>
      </a>
    </div>

    <!-- 下拉菜单 -->
    <el-dropdown @command="handleCommand">
      <span class="el-dropdown-link">
        {{ $route.query.name }} 个人中心
        <i class="el-icon-arrow-down el-icon--right"></i>
      </span>
      <el-dropdown-menu slot="dropdown">
        <el-dropdown-item command="a" icon="el-icon-edit">修改密码</el-dropdown-item>
        <el-dropdown-item command="b" icon="el-icon-switch-button">退出</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>

    <!-- 修改密码弹窗 -->
    <el-dialog title="修改密码" :visible.sync="dialogFormVisible" width="30%">
      <el-form :model="form">
        <el-form-item label="新密码" :label-width="iw">
          <el-input
            v-model="form.password"
            autocomplete="off"
            style="width:200px"
            type="password"
            placeholder="请输入新密码"
          ></el-input>
        </el-form-item>
        <el-form-item label="确认密码" label-width="100px">
          <el-input
            v-model="form.newpassword"
            autocomplete="off"
            style="width:200px"
            type="password"
            placeholder="请再次输入新密码"
          ></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { logOut } from "../../utils/auth";
export default {
  data() {
    return {
      dialogFormVisible: false, //弹窗的开关
      form: {
        password: "",
        newpassword: ""
      },
      iw: "100px"
    };
  },

  components: {},

  methods: {
    //功能：判断下拉菜单功能
    handleCommand(command) {
      if (command == "a") {
        //点击：修改密码
        // alert("修改密码");
        this.dialogFormVisible = true;
      } else {
        //点击：退出
        // alert("退出");
        logOut();
        this.$message({
          message: "退出成功",
          type: "success"
        });

        this.$router.push("/login");
      }
    }

    //功能：修改密码
    // edit() {}
  }
};
</script>

<style scoped>
/* 头部区域 */
.header {
  position: absolute;
  line-height: 50px;
  padding: 0px;
  top: 0px;
  left: 0px;
  right: 0px;
  background-color: #2d3a4b;
}
.logo {
  vertical-align: middle;
  /* 上 右 下 左 */
  padding: 0 10px 0 40px;
}
.company {
  position: absolute;
  color: white;
}
/* 下拉菜单 */
.el-dropdown {
  height: 50px;
  line-height: 50px;
  float: right;
  margin-right: 40px;
}
.el-dropdown-link {
  cursor: pointer;
  color: #fff;
}
.logo {
  padding: 0;
  margin: 0 10px 0 40px;
}
</style>